import request from '@/utils/request'
import requestUser from '@/utils/request/index4.js'
// api地址
const api = {
  userInfo: 'user/info',
  user: 'user',
  assets: 'user/assets',
  bindMobile: 'user/bindMobile',
  personal: 'user/personal',
  getUserAlarm: 'user/alarm/byUserId',
  setAlarmBatch: 'user/alarm/batch',
  getUserIdByPhone: 'user/getUserInfoByPhone',
  getUserIdByUuid: 'user/info/uuid',
  getAllMedical: 'medical/history/all'
}

// 当前登录的用户信息
export const info = (param, option) => {
  const options = {
    isPrompt: true, //（默认 true 说明：本接口抛出的错误是否提示）
    load: true, //（默认 true 说明：本接口是否提示加载动画）
    ...option
  }
  return requestUser.get(api.userInfo, param, options)
}

// 根据账户获取用户id
export const getUserIdByPhone = (phone) => {
	return requestUser.get(api.getUserIdByPhone, { phone });
}

// 获取用户报警
export const getUserAlarm = (data) => {
  return requestUser.get(api.getUserAlarm, data)
}

// 批量用户报警
export const setAlarmBatch = (alarmAddForms) => {
  return requestUser.post(api.setAlarmBatch, alarmAddForms, { 
	header: {
		'Content-Type': 'application/json',
	},
  })
}

// 修改用户信息
export const updateUserInfo = (data) => {
	return requestUser.put(api.userInfo, data);
}

// 根据id修改用户信息
export const updateUserInfoById = (data) => {
	return requestUser.put(api.user + "/" + data.id, data);
}

// 账户资产
export const assets = (param, option) => {
  return request.get(api.assets, param, option)
}

// 绑定手机号
export const bindMobile = (data, option) => {
  return request.post(api.bindMobile, data, option)
}

// 修改个人信息（头像昵称）
export const personal = (data, option) => {
  return request.post(api.personal, data, option)
}

// 根据uuid获取用户信息
export const getUserIdByUuid = (uuid) => {
	return requestUser.get(api.getUserIdByUuid, { uuid });
}

// 获取所有病史
export const getAllMedical = () => {
	return requestUser.get(api.getAllMedical);
}